﻿@{
    ViewData["Title"] = "Index";
    Layout = "~/Areas/Console/Views/Shared/_Layout.cshtml";
}
@section head{

    <script type="text/javascript">
        var renderTable;
        var userType = 0;
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            treetable: 'treetable-lay/treetable',
            index: 'lib/index'
        }).use(['table', 'treetable', 'index', 'laydate', 'form'], function () {
            var $ = layui.$
                , form = layui.form
                , admin = layui.admin
                , table = layui.table
                , element = layui.element
                , laydate = layui.laydate
                , parentFrameIndex = parent.layer.getFrameIndex(window.name);

            // 渲染表格
            renderTable = table.render({
                elem: '#table-datalist'
                , url: '/Console/CRMAccount/GetSearchListJson'
                , limit: 20
                , title: 'CRM账户'
                , cols: [[
                    { type: 'radio', fixed: 'left', title: '选择', width: 60 }
                    , { field: 'index', title: '序号', type: 'numbers', width: 60, templet: '#zizeng' }                    
                    , {
                        field: 'fullName', title: '姓名', templet: function (res) {
                            return res.fullName;
                        }
                    }
                    , {
                        field: 'CRMAccount', title: 'CRM账户', templet: function (res) {
                            return res.loginName;
                        }
                    }
                    , { field: 'telephone', title: '手机号' }
                    , { field: 'email', title: '邮箱' }
                    //, { field: 'level', title: '层级' }
                ]]
                , id: 'testReload'
                , toolbar: false
                , page: { layout: ['prev', 'page', 'next', 'refresh'] }
                , done: function (res) {
                    if (res.count == 0) {
                        $(".layui-table-main").html('<div class="layui-none">' + top.lang.noData + '</div>');
                    }
                    layer.closeAll('loading');
                    /**多语言初始化 */
                    top.SetListPageLanguage(layui);
                    top.SetSelectLanguage(layui);
                }
            });

            form.on('submit(search)', function (data) {
                //执行重载
                table.reload('testReload', {
                    page: { curr: 1, layout: ['prev', 'page', 'next', 'refresh'] }
                    , where: {
                        searchKey: $("#searchKey").val()
                    }
                });
            });

            form.on('submit(submit-form)', function (data) {
                //执行重载
                var checkStatus = table.checkStatus('testReload')
                    , data = checkStatus.data;
                if (data.length == 0) {
                    return;
                }
                parent.layui.$("#crmUp").val(data[0].fullName);
                parent.layui.$("#crmUpId").val(data[0].id);
                parent.layer.close(parentFrameIndex);
            });

            form.on('submit(closeBtn)', function (data) {
                parent.layer.close(parentFrameIndex);
            });
        });
    </script>
}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card" lay-filter="component-form-element">
                <div class="layui-card-body">
                    <div class="layui-form">
                        <div class="layui-form-item">
                            <label class="layui-form-label" lay-event="searchKey" style="width:200px;">姓/名/账号ID/手机/邮箱</label>
                            <div class="layui-input-block">
                                <input type="text" id="searchKey" name="searchKey" style="display:initial;width:500px" placeholder="searchKey" class="layui-input">
                                <button id="search" name="search" lay-event="search" lay-submit lay-filter="search" class="layui-btn">搜索</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="layui-tab-content">
                        <table class="layui-hide" id="table-datalist" lay-filter="table-datalist"></table>
                        <script type="text/html" id="zizeng">
                            {{d.LAY_TABLE_INDEX+1}}
                        </script>
                    </div>
                    <div class="layui-form">
                        <div class="layui-form-item layui-layout-admin">
                            <div class="layui-input-block">
                                <div class="layui-footer" style="left: 0;">
                                    <button class="layui-btn" lay-submit="" lay-filter="submit-form" lay-event="confirmBtn">确认</button>
                                    <button class="layui-btn layui-btn-primary" lay-submit="" lay-filter="closeBtn" lay-event="closeBtn">关闭</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

